<%--
    Document   : index
    Created on : Jun 1, 2016, 2:06:23 PM
    Author     : niugao
--%>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%
    String GOODID="goodid";
%>
<!DOCTYPE html>
<html>
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>主页</title>
    <%@ taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core"  %>
    <%--<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>--%>
    <link rel="stylesheet" type="text/css" href="../css/main.css">
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
    <script src="../js/jquery-1.12.4.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="../js/bootstrap.min.js"></script>
    <style>
        .p_num {
            width: 78px;
            height: 24px;
            border-top: solid 1px #d0d0d0;
            position: relative;
            border-bottom: solid 1px #d0d0d0;
            margin-top: -3px;
        }

        span.sy_minus,span.sy_plus {
            width: 15px;
            height: 24px;
            line-height: 24px;
            text-align: center;
            display: block;
            position: absolute;
            top: 0px;
            font-size: 14px;
            border: solid 1px #d0d0d0;
            background: #ebebeb;
            cursor: pointer;
            border-top: none;
            border-bottom: none;
        }

        span.sy_minus {
            left: 0px;
        }

        span.sy_plus {
            right: 0px;
        }

        input.sy_num {
            width: 30px;
            height: 18px;
            line-height: 24px;
            text-align: center;
            position: absolute;
            top: 0px;
            left: 17px;
        }

        span.sy_num {
            padding: 5px 8px;
            border: solid 1px #d0d0d0;
            border-left: none;
            border-right: none;
            cursor: pointer;
        }
    </style>
    <style>
        .container input {
            width: 100%;
        }

        .container div {
            margin: 0px 0px;
            outline: none;
        }
    </style>
    <script>


        //当点击删除图片的时候调用
        function deleteRow(img) {
            //出对话框，让用户确认是否删除
            var id = $("#new").attr("<%=GOODID%>");
            $.getJSON("/login/deletone",
                    {
                        id:id
                    },
                    function (json,status) {
                        if(json.isdelet==1){
                            alert("已删除订单！");
                        }
                        var r=json.id;
                        $("#"+r).remove();

                    }
            );
        }

        //点了对话框中的确定删除按钮
        function executeDel() {
            var id = $("#dialog").attr("<%=GOODID%>");
            //关掉对话框
            $("#dialog").modal("hide");
            $.getJSON("/login/addtocar",
                    {
                        id:id
                    },
                    function (json,status) {
                        if(json.message==0){
                            alert("请先登录");
                        }
                    }
            );
        }
        //点了对话框中的不删按钮
        function cancelDel() {
            //关掉对话框
            $("#dialog").modal("hide");
        }
    </script>
    //动态计算当前订单的总价
    <script type="text/javascript">
        $(document).ready (function ()
        {
            $ (".sy_minus").click (function ()
            {
                var me = $ (this), txt = me.next (":text");
                var val = parseFloat (txt.val ());
                val = val < 1 ? 1 : val;
                txt.val (val - 1);
            });

            $(".sy_plus").click (function ()
            {
                var me = $ (this), txt = me.prev (":text");
                var val = parseFloat (txt.val ());
                txt.val (val + 1);

            });
        })
    </script>
</head>
<body style="background: url(../img/bg5.jpg) no-repeat fixed center;padding:0px">

<div style="text-align: center;padding: 0px">
    <div class="container" style="padding: 0px">
        <div class="row" style="padding: 0px">
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2"  ></div>
            <div class="ol-lg-8 col-md-8 col-sm-8 col-xs-8">
                <jsp:include page="top_bar.jsp" flush="true"/>
            </div>
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" ></div>
        </div>
        <div class="row" style="height: 400px">
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" ></div>
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" >
                </br>
                <jstl:choose>
                    <jstl:when test="${message==1}">
                        <p>当前用户：${name}</p>
                        <p id="llgin"><input type="button" onclick="javascrtpt:window.location.href='/logon/openleft'" value="注销登录"></p>
                    </jstl:when>
                    <jstl:otherwise>
                        <p id="llgin"><input type="button" onclick="javascrtpt:window.location.href='/logon/openleft'" value="登录/注册"></p>
                    </jstl:otherwise>
                </jstl:choose>
                </br>
                </br>
                </br>
                <marquee direction="up" height="114" onmouseout="this.start()"
                         onmouseover="this.stop()" scrollAmount="1" scrollDelay="1">
                    <jstl:forEach items="${affiches}" var="std">
                        <img src="../img/sign.gif" />&nbsp;<a href="/affiche/open?affiche_id=${std.id}">${std.title}</a></br>
                    </jstl:forEach>
                    <%--<img src="../img/sign.gif">&nbsp;<a href="#" onClick="window.open('fg-afficheSelect.jsp?id=<%=afficheForm.getId()%>','','width=500,height=400');"><%=afficheForm.getName()%></a><br><br>--%>

                </marquee>

            </div>
            <div class="ol-lg-8 col-md- col-sm-8 col-xs-8" >
                <jstl:choose>
                    <jstl:when test="${noshopping==0}">
                        <h2>购物车里什么都没有哦！</h2>
                    </jstl:when>
                    <jstl:otherwise>
                        <form action="/goods/modify" method="post">
                            <table cellspacing="20"  border="0" width="67%">
                                <tr><td id="aaa"></td></tr>
                                <tr>
                                    <td>
                                        图片
                                    </td>
                                    <td>
                                        菜名
                                    </td>
                                    <td>
                                        单价
                                    </td>
                                    <td width="50px">
                                        数量
                                    </td>
                                    <td>

                                    </td>
                                </tr>
                                <jstl:forEach items="${ordertwos}" var="std">
                                    <tr id='${std.id}'>
                                        <td>
                                            <img src='${std.goodimage}' width="50px" height="50px">
                                        </td>
                                        <td>
                                                ${std.goodname}
                                        </td>
                                        <td>
                                                ${std.price}
                                        </td>
                                        <td class="p_num">
                                            </br>
                                            <span class="sy_minus" id="sy_minus_gid1">-</span>
                                            <input class="sy_num" id="sy_num_gid1" style="width: 52px" readonly="readonly" type="text" name=${std.goodid}  value="1" />
                                            <span class="sy_plus" id="sy_plus_gid1">+</span>

                                            <%--<input name=${std.goodid} type="text" width="50px" value="1">--%>
                                        </td>
                                        <td><img <%=GOODID%>='${std.id}' style="cursor: pointer" id="new" onclick='deleteRow(this)'  src='../img/del.png'/></td>
                                    </tr>
                                </jstl:forEach>
                            </table>
                            <input  type="submit" value="确认"  style="width: 100px">
                        </form>
                    </jstl:otherwise>
                </jstl:choose>

            </div>
        </div>

        <div class="row">
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2"  ></div>
            <div class="ol-lg-8 col-md-8 col-sm-8 col-xs-8">
                <jsp:include page="bottom.jsp" flush="true" />
            </div>
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" ></div>
        </div>
    </div>
</div>


<div class="modal fade" id="dialog" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    付款
                </h4>
            </div>
            <div class="modal-body">
                确认付款?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" onclick="cancelDel()">
                    取消
                </button>
                <button type="button" class="btn btn-primary" onclick="executeDel()">
                    是的
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>
</html>
